package edu.yonsei.iwb.sdt.test;

import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.RDF;
import java.util.Vector;
import edu.yonsei.iwb.sdt.SDTLearner;
import edu.yonsei.iwb.sdt.SDTLearningType;
import edu.yonsei.iwb.sdt.ontology.JenaModelType;
import edu.yonsei.iwb.sdt.ontology.OntologyModel;
import edu.yonsei.iwb.sdt.util.SDTLog;
import java.io.IOException;

public class DTLTest1 {

    Model model;
    String iri = "http://www.test.owl#";

    public void test() {
        //        기차 문제
        String ontology = "resources/3.owl";

        OntologyModel ontmodel = new OntologyModel(JenaModelType.MEMORY_MODEL);
        //        // 새로운 온톨로지 로딩
        ontmodel.loadOntology(ontology);
        this.model = ontmodel.getJenaModel();

        Resource s = this.model.createResource(iri + "ET");
        Property result = this.model.createProperty(iri + "resultValue");
        Property test2 = this.model.createProperty(iri + "test2");
        StmtIterator stmt = this.model.listStatements(null, RDF.type, s);

        while (stmt.hasNext()) {
            Statement st = stmt.nextStatement();
            Resource rr = st.getSubject();
            System.out.println(rr);


            StmtIterator stmt2 = this.model.listStatements(rr, result, (RDFNode) null);
            StmtIterator stmt3 = this.model.listStatements(rr, test2, (RDFNode) null);
            while (stmt2.hasNext()) {
                Statement st2 = stmt2.nextStatement();

                RDFNode rn = st2.getObject();

                System.out.println(rn.toString());

            }

            while (stmt3.hasNext()) {
                Statement st3 = stmt3.nextStatement();

                RDFNode rn = st3.getObject();

                System.out.println(rn.toString());

            }

//            System.out.println(st);
        }

    }

    public static void main(String[] args) throws IOException {
        String ontology = "./resources/test1.owl";
        String targetClass = "http://www.sample.owl#Person";
        String targetProperty = "http://www.sample.owl#target";
        
        OntologyModel ontmodel = new OntologyModel(JenaModelType.MEMORY_MODEL);
//        OntologyModel ontmodel = new OntologyModel(JenaModelType.TDB_MODEL);

//        // 새로운 온톨로지 로딩
        ontmodel.loadOntology(ontology);

        SDTLearner sdtl = new SDTLearner(targetClass, targetProperty, ontmodel, SDTLearningType.USE_CONJUNCTION_AND_DISJUNCTION);
        
        sdtl.setENTROPY_THRESHOLD(0);
        SDTLog.setLogType(SDTLog.DETAIL);
        sdtl.learningStart();

//        long startTime = System.nanoTime();
        System.out.println("");

    }
}
